package com.lesson3.singleton;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/8/27 10:27
 * 懒汉式线程不安全写法
 */
public class LazyType1
{
    public static void main(String[] args)
    {
        Singleton3 instance = Singleton3.getInstance();
        Singleton3 instance1 = Singleton3.getInstance();
        System.out.println(instance.hashCode()==instance1.hashCode());
    }
}

class Singleton3{
    private static Singleton3 singleton3;

    private Singleton3(){

    }

    public static Singleton3 getInstance(){
        if(singleton3==null){
            singleton3 = new Singleton3();
        }

        return singleton3;
    }
}
